package com.ubank.utils;

import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

import com.ubank.R;

public class MockDialog extends Activity
{
	EditText				pass;
	Button					bn;
	int						type;
	private static boolean	isLock	= false;

	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.lockscreen);
		isLock = true;
		bn = (Button) findViewById(R.id.lock_btn);
		pass = (EditText) this.findViewById(R.id.lock_pass);
		bn.setOnClickListener(new OnClickListener()
		{
			@Override
			public void onClick(View arg0)
			{
				String password = pass.getText().toString().trim();
				if (PublicUtils.checkInputNotNull(pass, password))
				{
					type = MainUtils.login(PublicUtils.getUserName(), password);

					if (PublicUtils.checkLogin(MockDialog.this, null,
							PublicUtils.getUserName(), pass, password, type,
							null))
					{
						finish();
					}
				}

			}
		});
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event)
	{
		switch (event.getKeyCode())
		{
			case KeyEvent.KEYCODE_BACK:
				return true;
			default:
				break;
		}
		return false;
	}

	public static boolean isLock()
	{
		return isLock;
	}

	@Override
	protected void onDestroy()
	{
		isLock = false;
		super.onDestroy();
	}
}
